from django.shortcuts import render, redirect
from .models import user

# Create your views here.


def login(request):
    if request.method == "POST":
        user_id = request.POST.get('user_id', None)
        user_pwd = request.POST.get('user_pwd', None)
        if user.objects.filter(user_id=user_id):
            if user.objects.filter(user_pwd=user_pwd):
                return redirect('index.html')
            else:
                return render(request, 'MRQC/login.html', {'pwd_error': '密码错误'})
        else:
            return render(request, 'MRQC/login.html', {'user_error': '用户名错误'})



    return render(request, 'MRQC/login.html')



